import { WereWolfBeforeNightPhase } from "@/werewolf/phases/beforeNight";
import { TimeOfDay, world } from "@minecraft/server";
import { ScriptRunner } from "@sapi-game/Runner/scriptRunner";
import { WereWolfPhaseView } from "../../phaseView";
import { ClassicViewTools } from "./func";

export class BeforeNightClassicView extends WereWolfPhaseView<WereWolfBeforeNightPhase> {
    override async runPhaseView(r: ScriptRunner) {
        await r.wait(40);
        for (let i = 0; i < 3; i++) {
            this.players.title("§7§l请注意", "§4§l黑夜将至,请立刻回家");
            await r.wait(9);
            this.players.runCommand("title @s clear");
            this.players.playSound("block.bell.hit", {
                pitch: 0.9,
                volume: 0.3,
            });
            await r.wait(2);
        }
        //重置结构
        ClassicViewTools.resetStructure();
        await r.wait(40);
        world.setTimeOfDay(TimeOfDay.Night);
        await r.wait(100);
        world.setTimeOfDay(TimeOfDay.Midnight);
        await r.wait(80);
        this.players.title("§0§l夜深了...");
        await r.wait(80);
        this.state.next();
    }
}
